package com.it.a08test;

import java.util.*;

public class Test4 {
    public static void main(String[] args) {
        //1.先定义一个Map集合
        HashMap<String, ArrayList<String>> hm = new HashMap<>();

        ArrayList<String> list1 = new ArrayList<>();
        list1.add("南京市");
        list1.add("苏州市");
        list1.add("无锡市");

        ArrayList<String> list2 = new ArrayList<>();
        list2.add("武汉市");
        list2.add("宜昌市");
        list2.add("鄂州市");

        ArrayList<String> list3 = new ArrayList<>();
        list3.add("石家庄市");
        list3.add("唐山市");
        list3.add("保定市");

        //添加到HashMap集合中
        hm.put("江苏省",list1);
        hm.put("湖北省",list2);
        hm.put("河北省",list3);

        //遍历集合
        Set<Map.Entry<String, ArrayList<String>>> entries = hm.entrySet();
        for(Map.Entry<String,ArrayList<String>> entry : entries){
            String key = entry.getKey();
            ArrayList<String> value = entry.getValue();
            StringJoiner sj = new StringJoiner(",","","");
            for(String s : value){
                sj.add(s);
            }
            System.out.println(key+"="+sj);
        }

    }
}
